package com.logic.modular.game.building.domain;

import cn.hutool.core.date.DateUtil;
import com.comment.pojo.domain.logic.core.CoreCityBuildings;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

/**
 * 内政建筑
 *
 * @author cxy
 * @since 2024-07-30 21:29:28
 */
@ApiModel("pvp城池内政")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class PvpCityBuildings implements Serializable {// swagger2,mybatis-plus
    @ApiModelProperty("对局id")
    private Long matchId;

    @ApiModelProperty("玩家id")
    private Long playerId;

    @ApiModelProperty("城池id")
    private Long coreCityId;

    @ApiModelProperty("内政建筑编号")
    private Integer no;

    @ApiModelProperty("内政建筑基础数据id")
    private Long corePvpCityBuildingId;

    @ApiModelProperty("类型")
    private Integer type;

    @ApiModelProperty("等级")
    private Integer level;

    @ApiModelProperty("状态 0空地 1正常 2建造中")
    private Integer status;

    @ApiModelProperty("完成时间")
    private Long finishTime;

    /**
     * 初始化 地块
     */
    public void init(Long playerId, Long targetCityId, Integer cityBuildNo, Long currentMatchId) {
        setMatchId(currentMatchId);
        setPlayerId(playerId);
        setCoreCityId(targetCityId);
        setNo(cityBuildNo);
    }

    /**
     * 建造
     */
    public void building(Long coreCityBuildingId, Long levelUpTime, CoreCityBuildings coreCityBuilding) {
        setCorePvpCityBuildingId(coreCityBuildingId);
        setStatus(2);
        setFinishTime(DateUtil.offsetSecond(new Date(), levelUpTime.intValue()).getTime());
        setLevel(coreCityBuilding.getLevel());
        setType(coreCityBuilding.getType());
    }

    public void clear() {
        status = 0;
        corePvpCityBuildingId = null;
        type = null;
        level = null;
        finishTime = null;
    }
}

